﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;

using AutoTestingFramework.Core;
using AutoTestingFramework.Core.Controls;
using OpenQA.Selenium;

namespace AutoTestingFramework.UnitTests.PageObjectModels
{
    class SampleTablePOM: PageObjectModelBase<SampleTablePOM>
    {
        private readonly IWebDriver _webBroswer;

        public SampleTablePOM(IWebDriver driver, TestBase test)
            : base(test)
        {
            _webBroswer = driver;
            this.Url = test.BaseUrl;
        }

        public bool MatchTabMain(DataTable MatchWith,string ignoreCellText,Func<string,string[]>fetchControlValue)
        {
            IWebElement table = _webBroswer.FindElement(By.Id("tabmain"));
            TableWebElement tabMain = new TableWebElement(table);

            CellMatchMetaData[] arrayofCMD = new CellMatchMetaData[3];
            arrayofCMD[0] = null;
            arrayofCMD[1] = null;
            arrayofCMD[2] = new CellMatchMetaData();
            arrayofCMD[2].ControlMatchMDs.Add(new ControlMatchMetaData(By.XPath("./a[1]"), ""));
            arrayofCMD[2].ControlMatchMDs.Add(new ControlMatchMetaData(By.XPath("./a[2]"), ""));
            arrayofCMD[2].ControlMatchMDs.Add(new ControlMatchMetaData(By.XPath("./input"), "SELECTED"));

            return tabMain.MatchTableData(MatchWith, ignoreCellText, arrayofCMD, fetchControlValue, true);

            
        }
    }
}
